<!DOCTYPE html>
<html lang="zh">

	<head>
		<meta charset="UTF-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<meta http-equiv="X-UA-Compatible" content="ie=edge" />
		<title>商城首页</title>
		<link rel="stylesheet" type="text/css" href="css/index.css" />
		<link rel="stylesheet" type="text/css" href="css/swiper.min.css" />
		<script type="text/javascript" src="js/jquery.min.js"></script>
		<script type="text/javascript" src="js/swiper.min.js"></script>
		<style>
			body {
				background-color: #f4f4f4;
			}
			
			.swiper-container {
				width: 1200px;
				height: 450px;
				margin: 0 auto;
			}
		</style>
	</head>

	<body>
		<div class="schooltop">
			<div class="schooltp">
				<div class="schooltp1">
					<div class="sctp1fl">
						<div class="splogin">
						</div>
					</div>
					<div class="sctp1fr">
						<div class="shopcart">
							<a class="nerr" href="shopcart.html" target="_blank">
								<img src="img/shopcrat.png" alt="" class="gwcimg" />
								<span class="gwctxt">我的购物车</span>
							</a>
						</div>
					</div>
				</div>
				<!--<div class="schooltp2">
					<p class="schoolmc">阿克苏地区库车中等职业技术学校--欢迎您</p>
				</div>-->
			</div>

		</div>
		<div class="index">
			<div class="lunbo">
				<div class="swiper-container">
					<div class="swiper-wrapper">
						<div class="swiper-slide"><img src="img/banner1.jpg" /></div>
						<div class="swiper-slide"><img src="img/banner2.jpg" /></div>
						<div class="swiper-slide"><img src="img/banner3.jpg" /></div>
					</div>
					<!-- 如果需要分页器 -->
					<div class="swiper-pagination"></div>

					<!-- 如果需要导航按钮 -->
					<div class="swiper-button-prev"></div>
					<div class="swiper-button-next"></div>

				</div>
			</div>
			<div class="indexCon">
				<div id="type" class="indexCon1">
					<!--<div class="shopitem">
						<p class="shoptxt">商品类别：干果</p>
						<p class="more">查看更多</p>
					</div>
					<div class="shopcon">
						<div class="shopxq">
							<div class="shopxpp">
								<a href="" title="切糕新疆纯手工新疆切糕特产美食整块手工玛仁糖零食糕点500g 新疆传统切糕">
									<p class="shoppic"><img src="//img14.360buyimg.com/n7/jfs/t1/117515/35/5149/418660/5eb251edEc05fae81/45ba6f462126332c.jpg" alt="" class="shopimg" /></p>
									<p class="shopprice"><span>￥</span><span class="jiage">68</span></p>
									<p class="shopms">切糕新疆纯手工新疆切糕特产美食整块手工玛仁糖零食糕点500g 新疆传统切糕</p>
								</a>
							</div>
						</div>
						
					</div>-->
				</div>
			</div>
		</div>
		<div class="shopbottom">
			<div class="shopbmcon">
				<p class="schoolname">
					<a href="http://www.worlduc.com/e/default.aspx?eid=2784009" target="_blank">阿克苏地区库车中等职业技术学校</a>
				</p>
				<p class="schoolname">学校地址：阿克苏地区库车县福鸿路26号</p>
			</div>
		</div>
	</body>

</html>
<script src="js/Global.js"></script>
<script src="js/jquery-1.11.0.js"></script>
<script type="application/javascript">
	var mySwiper = new Swiper('.swiper-container', {
		direction: 'horizontal',
		loop: true,
		autoplay: 1000,

		// 如果需要分页器
		pagination: '.swiper-pagination',

		// 如果需要前进后退按钮
		nextButton: '.swiper-button-next',
		prevButton: '.swiper-button-prev',
	})

	jQuery(document).ready(function() {
		getUser();
		$.ajax({
			type: "get",
			url: requesturl + "goods/all",
			async: false,
			xhrFields: {
				withCredentials: true
			},
			success: function(data) {
				if(data.status == "success") {
					load(data.data);
				} else {
					alert("登录失败：" + data.data.errMsg);
				}
			},
			error: function(data) {
				alert("网络原因发送失败：" + data.responseText);
			}
		});
	});

	function load(cdata) {
		var list = cdata.list;
		for(var i = 0; i < list.length; i++) {
			var cate = list[i];
			var type = '<div class="shopitem">' +
				'<p class="shoptxt">商品类别：' + cate + '</p>' +
				'<p class="more">查看更多</p>' +
				'</div>' +
				'<div class="shopcon">';
			$('#type').append(type);
			var goods = cdata[cate];
			console.log(goods);
			var length1 = (goods.length > 8) ? 8 : goods.length;
			for(var j = 0; j < length1; j++) {
				var good = goods[j];
				var content =
					'<div class="shopxq">' +
					'<div class="shopxpp">' +
					'<a href="./shop_detail.html?id='+good.id+'" title="' + good.title + '">' +
					'<p class="shoppic"><img src="./goodsimg/' + good.img + '" alt="" class="shopimg" /></p>' +
					'<p class="shopprice"><span>￥</span><span class="jiage">' + good.price + '</span></p>' +
					'<p class="shopms">' + good.content + '</p>' +
					'</a>' +
					'</div>' +
					'</div>';
				$('#type').append(content);
			}
			$('#type').append('</div>');
		}
	}
	
</script>
<script type="text/javascript" src="js/loginstate.js" ></script>